var showGoodsList = new Vue({

    el: "#showGoodsList",

    data: {
        //所属店铺ID
        shopId: {},
        fromCondition: {
            name: '',
            brand: '',
            model: '',
        },
        activeName: '1',
        //商品信息列表
        CommodityList1: [],
        CommodityList2: [],
        CommodityList3: [],
        CommodityList4: [],
        //模态窗口状态
        dialogFormVisible: false,
        map: {},
        currentPage1:'1',
        currentPage2:'1',
        currentPage3:'1',
        currentPage4:'1',
        pagesize:'12'
    },


    //提交时间方法
    methods: {
        //每页显示总条数
        handleSizeChange:function(size){
            var _this = this;
            _this.pagesize = size;
        },
        //当前页
        handleCurrentChange:function(currentPage,type){
            var _this = this;
            if(type==0){
                _this.currentPage1 = currentPage;
            }else if(type==1){
                _this.currentPage2 = currentPage;
            }else if(type==2){
                _this.currentPage4 = currentPage;
            }else{
                _this.currentPage3 = currentPage;
            }
        },

        onSubmit: function () {
            var _this = this;
            $.post("/home/commodity/Condition",
                {
                    "name": _this.fromCondition.name,
                    "brand": _this.fromCondition.brand,
                    "model": _this.fromCondition.model,
                    "shopId": _this.shopId
                },
                function (data) {
                    if (data.code == 200) {
                        debugger
                        _this.CommodityList1 = [];
                        _this.CommodityList2 = [];
                        _this.CommodityList3 = [];
                        _this.CommodityList4 = [];
                        for (var i = 0; i < data.data.commodityList.length; i++) {
                            if (data.data.commodityList[i].install == 0) {
                                _this.CommodityList1.push(data.data.commodityList[i]);
                                continue;
                            } else if (data.data.commodityList[i].install == 1) {
                                _this.CommodityList2.push(data.data.commodityList[i]);
                                continue;
                            } else if (data.data.commodityList[i].install == 2) {
                                _this.CommodityList3.push(data.data.commodityList[i]);
                                continue;
                            } else if (data.data.commodityList[i].install == 3) {
                                _this.CommodityList4.push(data.data.commodityList[i]);
                                continue;
                            }
                        }

                    } else {
                        this.$message.error("查询商品信息失败!");
                    }

                });

        },
        handleClick: function (tab, event) {
            console.log(tab, event);
        },
        //Excel上传成功后的回调函数
        excelSuccess: function (response) {
            this.$message.success(response);

        },
        //excel上传前的回调函数
        excelUpload: function (file) {
            this.$message.success('EXCEL信息解析中！'+this.shopId.id);
        },
        //excel上传失败后的回调函数
        excelError: function (err) {
            this.$message.error(err);
        },
        //跳转修改商品信息
        compile: function (Commodity) {
            var _this = this;
            $("#wrap-left").load("/person/addMerchandise.html", function () {
                //修改商品信息后都为待审批的状态
                Commodity.install = 3;
                addMerchandise.commodity = Commodity;
                addMerchandise.addModify = "update";
                addMerchandise.selectedOptions = Commodity.category.split("-");
                addMerchandise.initializeEdit(Commodity.details);

            });
        },
        //判断是否上架
        operation: function (commodity, type) {
            debugger
            var _this = this;
            commodity.install = type;
            $.post("/home/commodity/updateCommodity",
                {"commodity": JSON.stringify(commodity)},
                function (data) {
                    if (data.code == 200) {
                        this.$message("商品信息修改成功!");
                    } else {
                        this.$message("商品信息修改失败!");
                    }

                });
        },
        //打开模态窗口
        openWindow: function (commodity) {

            var _this = this;
            _this.dialogFormVisible = true;
            _this.map.commodity = JSON.stringify(commodity);
        },
        //上传成功后的回调函数
        handleAvatarSuccess: function (response, file, fileList) {
            this.$message.success(response);
            this.dialogFormVisible = false;
        },
        //上传前的回调函数
        beforeAvatarUpload: function (file) {

            this.$message('开始上传图片信息！');
        },
        //上传失败后的回调函数
        handleAvatarError: function (err, file, fileList) {
            this.$message(err);
        }

    },
    //页面加载后的初始化方法
    created: function () {

    }
});